package org.example.courseservice.repository;

import org.example.courseservice.entity.Course;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;

public interface CourseRepository extends JpaRepository<Course, Long> {
    List<Course> findByInstructorId(Long instructorId);
    
    List<Course> findByCategoriesContaining(String category);
    
    @Query("SELECT c FROM Course c WHERE c.published = true")
    List<Course> findAllPublishedCourses();
    
    @Query("SELECT c FROM Course c WHERE c.title LIKE %?1% OR c.description LIKE %?1%")
    List<Course> searchCourses(String keyword);
}